//
//  CYNavigationController.swift
//  WeiBo
//
//  Created by Mr_J on 16/3/3.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class CYNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    override func pushViewController(viewController: UIViewController, animated: Bool) {
   
         
        if childViewControllers.count > 0 {
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageNamed: "navigationbar_back_withtext", title: "返回", target: self, action: "back")
  
        
            
            if childViewControllers.count == 1 {
                viewController.navigationItem.leftBarButtonItem = UIBarButtonItem(imageNamed: "navigationbar_back_withtext", title: self.title, target: self, action: "back")
            }
            
            viewController.hidesBottomBarWhenPushed = true
 
        }
        super.pushViewController(viewController, animated: true)
        
    }
    
    func back() {
        popViewControllerAnimated(true)
    }
}
